package com.zl.easybuy.web;

import com.zl.easybuy.pojo.News;
import com.zl.easybuy.service.NewsService;
import com.zl.easybuy.service.ProductCategoryService;
import com.zl.easybuy.vo.ProductCategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/Home")
public class HomeController {
    @Resource
    ProductCategoryService productCategoryService;
    @Autowired
    NewsService newsService;

    @RequestMapping("/index")
    public String toIndex(Model model){
        List<ProductCategoryVo> productCategoryVoList =productCategoryService.findAllCategory();
        model.addAttribute("productCategoryVoList",productCategoryVoList);
        List<News> news=newsService.findNewsOf(5);
        model.addAttribute("news",news);
        return "forward:/pre/index.jsp";
    }
}
